<template>
  <el-dialog title="作业人员选择"
             :modal="false"
             :visible.sync="dialogForm"
             width="680px">
    <base-list ref="operator"
               :condition="condition"
               :datas.sync="operator"
               :pageSearch="pageSearch">
      <el-form :inline="true"
               :model="condition"
               class="search-form"
               slot="search"
               label-width="100px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="人员名称">
              <el-input v-model="condition['search_LIKE_name']"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-button type="primary"
                       icon="el-icon-search"
                       @click="loadData">查 询</el-button>
            <el-button type="primary"
                       @click="handleSelect">确 定</el-button>
            <el-button type="primary"
                       plain
                       @click="dialogForm=false">取 消</el-button>
          </el-col>
        </el-row>
      </el-form>
      <el-table slot="list"
                :data="operator"
                border
                stripe
                max-height="300">
        <el-table-column label="选择"
                         width="50">
          <template slot-scope="scope">
            <el-radio class="radio"
                      v-model="radio"
                      :label="scope.$index"
                      @change.native="getCurrentRow(scope.row)"></el-radio>
          </template>
        </el-table-column>
        <el-table-column prop="name"
                         label="人员名称"
                         
                         min-width="100"></el-table-column>
        <el-table-column prop="userName"
                         label="登录账户"
                         
                         min-width="100"></el-table-column>
        <el-table-column prop="org.name"
                         label="所属单位"
                         
                         min-width="150"></el-table-column>
        <el-table-column prop="dept.name"
                         label="所属部门"
                         
                         min-width="150"></el-table-column>
      </el-table>
    </base-list>
  </el-dialog>
</template>

<script>
import { getPersonList } from '@/api/system/person'
import autoSearchOrg from '@/components/autocomplete/autoSearchOrg'

export default {
  name: 'selectPerson',
  components: {
    autoSearchOrg
  },
  data() {
    return {
      condition: {
        search_LIKE_userName: ''
      }, // 查询条件
      operator: [], // table数组
      pageSearch: getPersonList, // 分页查询api接口
      dialogForm: false,
      radio: ''
    }
  },
  mounted() {},
  methods: {
    loadData() {
      this.$refs.operator.loadData()
    },
    // 确认选择
    handleSelect() {
      console.log(this.operator[this.radio])
      this.$emit('select', this.operator[this.radio])
      this.dialogForm = false
    },
    // 选择
    getCurrentRow(row) {
      // this.radio = row
    }
  },
  watch: {
    dialogForm(bool) {
      if (!bool) {
        this.radio = ''
        this.condition = {
          search_LIKE_userName: ''
        }
      }
    }
  }
}
</script>

<style scoped>
</style>
